Write a custom CUDA kernel to optimize `MMReLU`.

Formula:
  f(x) = x                                     if x >= 0
       = (2*sqrt(3t)/(9t))*x^2 + x             if -sqrt(3t) < x < 0
       = t / x                                  if x <= -sqrt(3t)

Problem Analysis:
1. Memory Bound: This is an element-wise activation with multiple branches.
2. Operator Chaining: PyTorch implementation requires multiple `torch.where` calls and arithmetic operations, creating high memory traffic.

Optimization Strategy: Fused Element-wise Kernel with Vectorization

1. One-Thread-per-Element: Map each element to a CUDA thread.

2. Vectorized Loads (float4): Use `float4` to process 128 bits per memory transaction.

3. Fused Branching Logic:
   - Pre-compute constants like `sqrt(3t)` and coefficients on the host.
   - Kernel logic: Use a nested `if-else` to handle the three segments.
   - All computations are fused in registers.

4. One-Pass: Fuse all steps into a single read-compute-write kernel.
  
Here's an example to show you the syntax of inline embedding custom CUDA operators in torch: The example given architecture is:   
  
```python
import torch
import torch.nn as nn
import math

BATCH_SIZE = 4096
HIDDEN_DIM = 4096
SHAPE = (BATCH_SIZE, HIDDEN_DIM)

T_VALUE = 1.0

class MMReLU(nn.Module):
    '''
    MMReLU: A Simple and Smooth Activation Function with High Convergence Speed
    https://ieeexplore.ieee.org/document/9674529
    Formula:
      f(x) = x                                     if x >= 0
           = (2*sqrt(3t)/(9t))*x^2 + x             if -sqrt(3t) < x < 0
           = t / x                                 if x <= -sqrt(3t)
    '''
    def __init__(self, t=1.0):
        super(MMReLU, self).__init__()
        self.t = t
        self.sqrt_3t = math.sqrt(3 * t)
        self.coeff = (2 * self.sqrt_3t) / (9 * t) if t > 0 else 0.0

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        # Part 1: x >= 0 -> x
        # Part 2: -sqrt(3t) < x < 0 -> quadratic
        # Part 3: x <= -sqrt(3t) -> reciprocal
        
        part1 = x
        part2 = self.coeff * x.pow(2) + x
        part3 = self.t / (x + 1e-9) # Add epsilon for stability
        
        neg_res = torch.where(x > -self.sqrt_3t, part2, part3)
        
        res = torch.where(x >= 0, part1, neg_res)
        
        return res


class Model(nn.Module):
    def __init__(self, t=1.0):
        super(Model, self).__init__()
        self.act = MMReLU(t=t)
    
    def forward(self, x):
        return self.act(x)

def get_inputs():
    input_tensor = torch.randn(SHAPE, dtype=torch.float32) * 2.0
    return [input_tensor.contiguous()]

def get_init_inputs():
    return [T_VALUE]